package com.mrdeer.common.entity.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.mrdeer.common.base.Converter;
import com.mrdeer.common.entity.beans.PageEntity;
import com.mrdeer.common.entity.sys.Permission;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.beans.BeanUtils;

@Data
@Accessors(chain = true)
public class PermissionDTO extends Permission implements Converter<Permission, PermissionDTO> {

    @JsonInclude(JsonInclude.Include.NON_NULL)
    private PageEntity page;

    @Override
    public void convert2Do(Permission permission) {
        BeanUtils.copyProperties(this, permission);
    }

    @Override
    public PermissionDTO convert(Permission permission) {
        BeanUtils.copyProperties(permission, this);
        return this;
    }
}
